package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Order;
import com.itheima.res.OrderRes;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface OrderMapper extends BaseMapper<Order> {

    @Select("select \n" +
            "date_format(o.order_date,'%Y-%m-%d') order_date,\n" +
            "(\n" +
            "case when o.order_type = 0 then '微信'\n" +
            "else '电话' end) order_type,\n" +
            "m.name as member,\n" +
            "s.name as setmeal \n" +
            "from order_t o\n" +
            "left join member_t m on m.id = o.member_id\n" +
            "left join setmeal_t s on s.id = o.setmeal_id\n" +
            "where o.id = #{orderId}")
    public OrderRes selectOrderInfo(@Param("orderId") Long orderId);

}
